import Vue from 'vue';
// import MintUI from 'mint-ui';
import 'mint-ui/lib/style.css'
import VueRouter from 'vue-router';

import App from './App.vue';
import routes from './router/router';
import { routerMode } from './config/env';

Vue.config.productionTip = false

// 按需引入mint-ui
import { 
  Button, Cell, 
  Tabbar, TabItem,
  Header, } from 'mint-ui'

Vue.component(Button.name, Button);
Vue.component(Cell.name, Cell);
Vue.component(Tabbar.name, Tabbar);
Vue.component(TabItem.name, TabItem);
Vue.component(Header.name, Header);

Vue.use(VueRouter);
// Vue.use(MintUI);
const router = new VueRouter({
  routes,
  mode: routerMode,
  strict: process.env.NODE_ENV !== 'production',
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      if (from.meta.keepAlive) {
        from.meta.savedPosition = document.body.scrollTop;
      }
      return { x: 0, y: to.meta.savedPosition || 0 }
    }
  }
})

new Vue({
  router,
  components: { App },
  render: h => h(App),
}).$mount('#app')
